#ifndef CSV_HEADER
#define CSV_HEADER

// this header needs
#include <stdio.h>
#include "../TEXT.h"

// Comma Separated Values files or CSV files
// important variables
extern umax ENC_INT_COMMA;  
extern umax ENC_INT_NEWLN;
// whitespace
extern umax * ENC_INT_WHITESPACE;

// enum to indicate the characteristic of a CSV cell
// has an element, the cell exists, neither of them exist
typedef enum
{
  TEXT_CSV_ELEM_NO_CELL,  // cell does not exist
  TEXT_CSV_CELL_EMPTY,    // cell exists (is empty)
  TEXT_CSV_ELEM_EXISTS,   // element and cell exist
} text_csv_elem_state;

// struct to store the pointer to a single CSV element and 
// a text_csv_elem_state to indicate the state of the element there
typedef struct
{
  byte * PTR; 
  text_csv_elem_state STATE;
} text_csv_elem;

// struct to store some characteristics of a CSV file
typedef struct
{
  umax ROW_CNT;           // number of rows on the CSV
  umax MX_COL_CNT;        // maximum number of columns for a single CSV row
  umax * ROW_COL_CNT;     // array with the column count for each CSV row
  text_csv_elem ** ELEMS; // allocated array with pointers to text_csv_elem structs
} text_csv;

// some functions for CSV files
umax count_csv_rows(void * src, umax ssize);
umax count_csv_mx_cols(void * src, umax ssize);

// build/close/print a complete text CSV structure
text_t check_text_csv(text * csv_f);
text * open_text_csv(char * file_path);
void close_text_csv(text * text_csv_file);
void print_text_csv(text * text_csv_file);

#include "CSV.c"

#endif // CSV_HEADER
